home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 5_11.lha / 5_11 / 5_10a.h next >
C/C++ Source or Header  |  1993-08-08  |  1KB  |  62 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  6. * The C++ Answer Book */
  7. * Tony Hansen */
  8. * All rights reserved. */
  9. / exercise 5.10
  10. / class table
  11. ifndef TABLE_H
  12. define TABLE_H
  13.  
  14. include <string.h>
  15.  
  16. * declare the class which contains the names, */
  17. * values and pointers for a list of these names */
  18. truct name
  19.  
  20.    char *string;
  21.    name *next;
  22.  
  23.    union
  24. {
  25. double dvalue;
  26. float fvalue;
  27. void *pvalue;
  28. void (*pfvalue)();
  29. long lvalue;
  30. short svalue;
  31. unsigned long ulvalue;
  32. unsigned short usvalue;
  33. };
  34.  
  35.    name(char *str)
  36.    {
  37. string = new char[strlen(str) + 1];
  38. strcpy(string, str);
  39. dvalue = 0;
  40.    }
  41.  
  42.    ~name()
  43.    {
  44. delete string;
  45.    }
  46. ;
  47.  
  48. lass table
  49.  
  50.    name **tbl;
  51.    int size;
  52.  
  53. ublic:
  54.    table(int sz = 23);
  55.    ~table();
  56.  
  57.    name *look(char*, int = 0);
  58.    name *insert(char *s) { return look(s, 1); }
  59.    name *lookfor(char *s) { return look(s, 2); }
  60. ;
  61. endif /* TABLE_H */
  62.